﻿using NFine.Application.BusinessManage;
using NFine.Application.SystemManage;
using NFine.Code;
using NFine.Domain.Entity.BusinessManage;
using NFine.Domain.Entity.SystemManage;
using System.Collections.Generic;
using System.Web.Mvc;

namespace NFine.Web.Controllers
{
    [HandlerLogin]
    public class HomeController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            var login = OperatorProvider.Provider.GetCurrent();
            UserEntity userEntity = new UserApp().GetForm(login.UserId);
            D_GroupMemberEntity GroupEntity = new D_GroupMemberApp().GetEntity(userEntity.F_Id, userEntity.CurrentGroupID);
            ViewBag.CurrentManager = userEntity.CurrentManager;
            if (GroupEntity != null)
            {
                ViewBag.GroupStatusText = GroupEntity.GroupStatusText;
                if (GroupEntity.IsOperator)
                    ViewBag.OperatorName = "[经营组]";
                else
                    ViewBag.OperatorName = "[消费组]";
            }                
            List<UserEntity> list = new UserApp().GetChilds(userEntity.F_Id);
            for (int i = 0; i < list.Count; i++)
            {
                if (i == 0)
                    ViewBag.L_Moeny = list[0].CumulativePoints.SafeValue();
                else
                    ViewBag.R_Moeny = list[1].CumulativePoints.SafeValue();
            }
            return View();
        }
        [HttpGet]
        public ActionResult Default()
        {
            return View();
        }
        [HttpGet]
        public ActionResult About()
        {
            return View();
        }
    }
}
